<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2022/5/7
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>

</head>

<body>
<div class="x-nav">
			<span class="layui-breadcrumb">
				<a href="">首页</a>
				<a href="">演示</a>
				<a>
					<cite>导航元素</cite></a>
			</span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">

    <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加文件','/myFileAdd',600,400)"><i
                class="layui-icon"></i>新增文件</button>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>文件名</th>
            <th>文件地址</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="tb">


        </tbody>
    </table>

</body>
    <script>
        function loadData() {
            $.ajax({
                url:"/myFileAjax/fileList",
                type:"post",
                dataType:"json",
                success:function (rs) {
                    if (rs.code == 200) {
                        //渲染列表
                        var html = "";
                        for (var i = 0;i<rs.data.length;i++) {
                            html += "<tr>"
                                + "<td>" + rs.data[i].fileId + "</td>"
                                + "<td>" + rs.data[i].fileName + "</td>"
                                + "<td>" + rs.data[i].fileUrl + "</td>"
                                + "<td class='td-manage'>"
                                +"<a title='文件下载' onclick='downLoad(this)' href='javaScript:;'>" + "文件下载</a>"
                                + "</td>"
                            +"</tr>"
                        }
                        $("#tb").html(html);
                    }
                }
            })
        }
        //页面打开加载
        $(function () {
            loadData();
        })

        //文档下载
        function downLoad(obj) {
            var fileName = $(obj).parent().parent().find("td").eq(1).text();
            window.location.href="/file/downLoad?fileName="+fileName
        }
    </script>



</html>

